package com.qianbei.view.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;

import com.qianbei.R;
import com.qianbei.bean.GetBindBean2;
import com.qianbei.common.adapter.CommonAdapter;
import com.qianbei.common.adapter.ViewHolder;
import com.qianbei.common.net.control.ServerControl;
import com.qianbei.common.net.control.ServerResult;
import com.qianbei.common.net.okhttp.RequeastBean;
import com.qianbei.view.EpcDataBase;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by gaoml on 2018/2/8.
 */

public class GetCarAdapter extends CommonAdapter<GetCarBean> {
    private int tempPostion = -1;
    public GetCarAdapter(Context context, List<GetCarBean> data, int itemLayoutId) {
        super(context, data, itemLayoutId);
    }
    public GetCarAdapter(Context context) {
        super(context, R.layout.gufei_item_getcar);
    }

    @Override
    public void convert(ViewHolder helper, final GetCarBean item, final int position) {
        helper.setText(R.id.main_list_item_text, item.customerName);
        helper.setText(R.id.main_list_item_text_1,"线路编号: "+ item.routeNo);
        ((CheckBox) (helper.getView(R.id.main_list_item_checkBox))).setChecked(getItem(position).isChecked);
       /* 挫写法
       if(mDatas.get(position).isChecked){//状态选中
            ((CheckBox) (helper.getView(R.id.main_list_item_checkBox))).setChecked(true);
        }else{
            ((CheckBox) (helper.getView(R.id.main_list_item_checkBox))).setChecked(false);
        }*/
    }

    public void setChecked(int position) {
        if (tempPostion != -1 && tempPostion != position) {
            getItem(tempPostion).isChecked = false;
        }
        getItem(position).isChecked = true;
        tempPostion = position;
        notifyDataSetChanged();
    }

    public int getCheckedPosition() {
        return tempPostion;
    }
}
